<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="button" onclick="disp_year()" value="请输入您的出生年份"/>
		<script>
			function disp_year()
			{
				var year=prompt("请输入您的出生年份","");
				if(year!="")
				{
					document.write('您今年'+(2021-year)+'岁');
				}
				else
				alert('输入年龄不能为空！！');
			}
		</script>
	</body>
</html>
